function Search_UserMsg() {
    var user_name=($("#user_name").val()==undefined||$("#user_name").val().length==0)?"":$("#user_name").val();
    var grade=($("#UserGrade").val()==undefined||$("#UserGrade").val().length==0)?"":$("#UserGrade").val();
    var where={grade:grade,user_name:user_name};
    RenderTable("#UserList",'','/CenterInc/view_json/admin/User_msg_json.aspx',true,[[
        {field: 'caozuo', title: '操作', fixed: 'left',type:'checkbox'}
        ,{field: 'Id', title: 'ID', sort: true}
        ,{field: 'Name', title: '用户名'}
        ,{field: 'Grade', title: '权限', sort: true}
        ,{field: 'Article_count', title: '文章数',  sort: true}
        ,{field: 'Follow_count', title: '关注数',  sort: true}
        ,{field: 'Fans_count', title: '粉丝数',  sort: true}
        ,{field: 'Comment_count1', title: '评论数',  sort: true}
        ,{field: 'Balance', title: '余额',  sort: true}
        ,{field: 'ShopCount1', title: '消费',  sort: true}
        ,{field: 'Level', title: '等级',  sort: true }
        ,{field: 'Img', title: '头像'}
        ,{field: 'Email', title: '邮箱'}
        ,{field: 'toolbar', title: '操作',width:135, align:'center',toolbar:'#table_bar'}
    ]],'','','post',where);
}
function getSelectedRowMsgDel() {
    var checkStatus = table.checkStatus('UserList'); //idTest 即为基础参数 id 对应的值
    console.log(checkStatus.data); //获取选中行的数据
    var count=checkStatus.data.length;
    if(count==0){
        Popup.msg("您暂未选择任何数据",{icon: 5});
        return;
    }
    Popup.confirm("请确认是否需要删除选中的数据？",
        {btn: ['是','否']}
        ,function () {
            var i=0;
            for(;i<count;i++){
                $.post("/CenterInc/view_inc/admin/Admin_User_inc.aspx?mode=1",{user_id:checkStatus.data[i].Id},function (data) {
                    if(data["error"]!=undefined){
                        Popup.msg("用户id："+checkStatus.data[i].Id+"删除失败："+data["error"],{icon: 5});

                    }
                });
            }
            Popup.msg("选中数据删除成功，可在回收站进行恢复",{icon: 1});
            setTimeout("window.location.reload()",2000);
            return;
        });
}
function table_event() {
    table.on('tool(UserList)', function(obj){ //注：tool 是工具条事件名，test 是 table 原始容器的属性 lay-filter="对应的值"
        var table_Row = obj.data //获得当前行数据
            ,layEvent = obj.event; //获得 lay-event 对应的值
        console.log(table_Row);
        if(layEvent === 'del'){
            layer.confirm('请确认是否删除？', {
                btn: ['是','否'] //按钮
            }, function(){
                $.post("/CenterInc/view_inc/admin/Admin_User_inc.aspx?mode=1",{user_id:table_Row.Id},function (data) {
                    if(data["error"]!=undefined){
                        layer.msg(data["error"], {icon: 5});
                        return;
                    }
                    layer.msg(data["msg"], {icon: 1});
                    setTimeout("window.location.reload()",2000);
                });

            });
            console.log(table_Row);
        } else if(layEvent === 'edit'){
            window.parent.open_LoginResistPopup('编辑用户','/admin/User/User_Add.aspx?user_id='+table_Row.Id,'460px','360px',false);
            return;
        }
    });
}
function getSelectedRowMsgMove() {
    var checkStatus = table.checkStatus('UserList'); //idTest 即为基础参数 id 对应的值
    console.log(checkStatus.data); //获取选
    var grade=$("#MoveGrade").val();
    console.log(grade);
    var count=checkStatus.data.length;
    if(count==0){
        Popup.msg("您暂未选择任何数据",{icon: 5});
        return;
    }
    if(grade.length==0){
        Popup.msg("请选择目录",{icon: 5});
        return;
    }
    Popup.confirm("请确认是否需要更改指定数据为指定权限？",
        {btn: ['是','否']}
        ,function () {
            var i=0;
            for(;i<count;i++){
                $.post("/CenterInc/view_inc/admin/Admin_User_inc.aspx?mode=4",{user_id:checkStatus.data[i].Id,grade:grade},function (data) {
                    if(data["error"]!=undefined){
                        Popup.msg("用户id："+checkStatus.data[i].Id+"移动失败",{icon: 5});

                    }
                });
            }
            Popup.msg("选中数据更改权限成功",{icon: 1});
            setTimeout("window.location.reload()",2000);
            return;
        });
}

function User_edit(id) {
 var newPassword=$("#NewPassword").val();
 var RePassword=$("#RePassword").val();
 var Email=$("#email").val();
 var balance=$("#balance").val();
 var grade=$("#grade").val();
    if(NotEmpty(newPassword,RePassword,Email,balance,grade)){
        Popup.msg("禁止留空",{icon:5});
        return;
    }
    if(RegChar(newPassword)){
        Popup.msg("不能带有特殊字符",{icon:5});
        return;
    }
    if(newPassword!=RePassword){
        Popup.msg("两次输入密码需要相同",{icon:5});
        return;
    }
    if(ReqEmailChar(Email)){
        Popup.msg("您输入的不是邮箱",{icon:5});
        return;
    }
    $.post("/CenterInc/view_inc/admin/Admin_User_inc.aspx?mode=2",{Password:newPassword,email:Email,balance:balance,grade:grade,user_id:id},function (data) {
        if(data["error"]!=undefined){
            Popup.msg(data["error"],{icon:5});
            return;
        }
        Popup.msg(data["msg"],{icon:1});
        setTimeout("window.location.reload()",2000);
    });
}

function User_Add() {
    var user_name=$("#user_name").val();
    var newPassword=$("#NewPassword").val();
    var RePassword=$("#RePassword").val();
    var Email=$("#email").val();
    var balance=$("#balance").val();
    var grade=$("#grade").val();
    if(NotEmpty(newPassword,RePassword,Email,balance,grade,user_name)){
        Popup.msg("禁止留空",{icon:5});
        return;
    }
    if(fontMaxMin(5,20,user_name)||fontMaxMin(5,20,newPassword)){
        Popup.msg("用户名或密码需要在5~20个字符之间",{icon:5});
        return;
    }
    if(RegChar(newPassword,user_name)){
        Popup.msg("不能带有特殊字符",{icon:5});
        return;
    }
    if(newPassword!=RePassword){
        Popup.msg("两次输入密码需要相同",{icon:5});
        return;
    }
    if(ReqEmailChar(Email)){
        Popup.msg("您输入的不是邮箱",{icon:5});
        return;
    }
}